package com.riven.redisson.concurrent;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.reflect.MethodSignature;

/**
 * @author riven
 * @since 2025-05-26
 */
@Slf4j
public class DefaultProviderLockSubjectResolver extends BaseLockSubjectResolver {

    private final LockSubjectProvider defaultProvider;

    public DefaultProviderLockSubjectResolver() {
        this.defaultProvider = null;
    }

    public DefaultProviderLockSubjectResolver(LockSubjectProvider defaultProvider) {
        this.defaultProvider = defaultProvider;
    }

    @Override
    public Object doResolve(MethodSignature methodSignature, Object[] args) {
        if (defaultProvider == null) {
            return null;
        }
        return defaultProvider.getSubject();
    }
}
